import Axios from "axios";

export function request(config) {
  // 创建实例
  const instance = Axios.create({
    baseURL: 'http://localhost:8001/api/v1',
    timeout: 5001
  })

  // 拦截器
  // 请求拦截
  instance.interceptors.request.use(config => {
    config.headers.authorization = window.sessionStorage.getItem('token')
    return config
  },error => {
    console.log("network err")
  })

  // 响应拦截
  instance.interceptors.response.use(res => {
    return res.data
  },error => {
    console.log("response err")
  })

  return instance(config)
}

